import { Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn } from "typeorm";
import { User } from "./user.entity";
import { BaseEntity } from "../common/entities/base.entity";
import { Gender } from "../enum/gender.enum";

/**
 * 用户档案实体 - 存储用户详细信息
 */
@Entity()
export class Profile extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number; // 档案ID

  @Column({
    type: "enum",
    enum: Gender,
    default: Gender.FEMALE,
  })
  gender: Gender; // 性别

  @Column({ nullable: true })
  photo: string; // 头像URL

  @Column({ unique: true })
  email: string;

  @Column({ nullable: true })
  address: string; // 地址

  // 一对一关系：档案对应一个用户
  @OneToOne(() => User, (user) => user.profile)
  @JoinColumn()
  user: User;
}
